Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cone Search library #86

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Cone Search library #86

wants to merge 15 commits into from

Conversation

at88mph
Copy link
Member

@at88mph at88mph commented Jul 26, 2022

No description provided.

@@ -0,0 +1,68 @@
# cadc-conesearch (1.0.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mention specific versions here (or below in sample gradle build) because they will fall out of date before we know it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
```

`${HOME}/config/cadc-conesearch.properties`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting that the service woulds have the config (rather than the lib - usually, reserve library config for cases where the lib is a plugin that the app/service cannot configure)... it really doesn't help to provide this since the ctor for TAPQueryGenerator takes all the necessary config as arguments anyway (it's utility).

Also, it won't suffice for a containerised cone service in CADC/CANFAR for a variety of reasons, so it will be code we don't use. If you want the ConeSearchConfig class in then alma impl, that's fine, but I wouldn't include it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, done.

Capture the Cone Search parameters and translate to ADQL to be sent to a TAP service.

```java
final ConeSearchConfig coneSearchConfig = new ConeSearchConfig(); // Ensure the cadc-conesearch.properties exists.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not a fan of code samples like this. It will be wrong and not even compile in no time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


package org.opencadc.conesearch;

public enum ParameterNames {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the same approach as cadc-sia: ConeParamValidator extends CommonParamValidator from cadc-dali and add the SCS-specific params and methods. "common" just means "used in more than one standard"

Then maybe you need to add List<Double> validateDouble(...) to the CommonValidator instead of a whole class (and test class) here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

protected final String midVerbositySelectList;
protected final String highVerbositySelectList;

public TAPQueryGenerator(final String catalog, final String lowVerbositySelectList,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The position column also must be a ctor arg since it is tightly coupled with the table name. catalog is pretty generic so I would use tableName and posColumnName.

The verb-dependent select lists I see as a pretty fragile way to pick columns, but I can't think of anything bulletproof so I guess simplest is the right choice now. I can imagine too many variations and they would all be complex :-)

This generator is a different style from the sia2/AdqlQueryGenerator; that class takes the input param map in the ctor and returns the TAP params from a no-arg `getParameterMap(). I can see you looked at that because both of them have the same incorrect comment mentioning the REQUEST param (which no longer exists in TAP). The sia2 style makes a single use generator, while this allows calling code to generate different queries with different inputs; there are no use cases for the latter since a cone search request is inherently single query.

Finally, the ctor should check all args for null and throw IllegalArgumentException if necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done.

/**
* Class to produce an ADQL query from a set of Parameters
*/
public class TAPQueryGenerator extends CommonParamValidator {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in another comment, I expected something like ConeParamValidator extends CommonParamValidator and that the query generator would use it (rather than be the thing extending). It separates the two things and allows the ConeParamValidator to be used without the query generator. Given that SCS has 3 params that map to one Circle constraint, I would probably have a method like

public Circle ConeParamValidator.validateCone(Map<String, List<String>> params)

to encapsulate/manage that old style.

So, you should end up with ConeParamValidator and TAPQueryGenerator (ugh, acronyms in class names).

final Map<String, Object> queryParameterMap = new HashMap<>();

// Obtain and, if necessary, provide a default RESPONSEFORMAT.
final String requestedResponseFormat = getFirstParameter(ParameterNames.RESPONSEFORMAT.name(), parameters,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConeSearch allows for output format other than VOTable?

If so, use CommonParamValidator.getResponseFormat(...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final String requestedOutputVerbosity = getFirstParameter(ParameterNames.VERB.name(), parameters,
Integer.toString(MID_VERB_VALUE));
final NumberParameterValidator outputVerbosityValidator =
new NumberParameterValidator(false, TAPQueryGenerator.MIN_VERB_VALUE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than a separate NumberParameterValidator, just use CommonParamValidator.validateInteger(...). You'll have to deal with getting the first value from the list here (multi-valued params are the norm now so not generically supported in CommonParamValidator)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done.

final int outputVerbosity = outputVerbosityValidator.validate(requestedOutputVerbosity);

// Obtain and validate the MAXREC value with a default if necessary.
final String requestedMaxRecords = getFirstParameter(ParameterNames.MAXREC.name(), parameters,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAXREC should be added to the CommonParamValidator, eg

public Integer getMaxRec(Map<>, Integer defaultValue, Integer maxValue)

where both integer args could be null (server-side choice). There is a MaxRecValidator in cadc-dali that is used in TAP, but it currently requires a Job so isn't usable here, but the code in it's validate() method is easily adapted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done.

@at88mph
Copy link
Member Author

at88mph commented Jul 27, 2022

Review work submitted. They're a little lengthy, and now include changes to the CommonParamValidator in cadc-dali.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants